<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<#include "/common/plateform/include/common-base.ftl">
	<title>数据导出配置</title>
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

	<!-- top start -->
	<#include "/common/plateform/top.ftl">
	<!-- top end -->

	<!-- left start -->
	<#include "/common/plateform/left-project.ftl">
	<!-- left end-->

	<!-- Main start -->
	<div class="content-wrapper">
		<!-- Main start -->
		<section class="content">
			<div class="row">
				<div class="col-xs-12 ibox">
					<!--搜索  start -->
					<div class="box box-info">

						<!--搜索title  start -->
						<div class="box-header with-border">
							<h3 class="box-title"><i class="fa fa-cog"></i> 接口数据导出配置
								<div class="pt10 pb10 fx8 f14">${formName}_${pageName} - ${title}</div>
								<div class="f12">全局设置：
										<span class="pr15">1)表头全部按:
											<select type="text" id="select_all_expTitleType" onchange="changeExportConfAttr('expTitleType',$(this).val())">
												<option value="CN" selected>中文标题</option>
												<option value="FD">英文字段</option>
												<option value="EN">英文属性</option>
											</select>
										</span>
										<span class="pr15">2)表头是否大写:
											<select type="text" id="select_all_ifTitleCap" onchange="changeExportConfAttr('ifTitleCap',$(this).val())">
												<option value="F" selected>否</option>
												<option value="T">是</option>
											</select>
										</span>
								</div>
							</h3>
							<div class="box-tools pull-right">
								<button onclick="refresh();" class="btn btn-default btn-xs" type="button"><i class="fa fa-refresh"></i> 刷新</button>
								<button onclick="testExportData();" class="btn btn-success btn-xs" type="button"><i class="fa fa-file-excel-o"></i> 导出测试</button>
								<button onclick="toBack();" class="btn btn-default btn-xs" type="button"><i class="fa fa-reply"></i> 返回</button>
							</div>
						</div>
						<!-- /.box-header -->
						<div class="box-body mytab2">
							<div class="nav-tabs-custom">
								<ul class="nav nav-tabs">
									<li class="active"><a href="#tab_setbox_1" data-toggle="tab">1.常用配置</a></li>
									<li><a href="#tab_setbox_2" data-toggle="tab">2.自定义配置</a></li>
								</ul>
								<div class="tab-content">
									<div class="tab-pane active" id="tab_setbox_1">
										<div class="pb5 fx8"><i class="fa fa-info-circle "></i> 以下数据来源系统数据表管理中所维护的字段信息</div>
										<table  data-coftype="1" class="table table-bordered table-hover box-min-table">
											<thead class="bg-success">
											<tr>
												<th>字段/属性/名称</th>
												<th class="text-center w120">导出[已选<span id="span_expCheckedTotal" class="red">0</span>]</th>
												<th class="w200">中文标题</th>
												<th class="w150">数据来源配置/顺序</th>
												<th class="w200">其他配置</th>
												<th class="w100">操作</th>
											</tr>
											</thead>
											<tbody id="dataList-body">
											</tbody>
										</table>
									</div>
									<div class="tab-pane " id="tab_setbox_2">
										<div class="pb5 fx8">
											<i class="fa fa-info-circle "></i> 可在此新增其他字段（比如插件中返回了数据表未定义的字段）
											<button class="btn btn-info btn-xs pull-right" onclick="addExportCustItem()"><i class="fa fa-plus-circle"></i> 增加一项</button>
										</div>
										<table  data-coftype="2" class="table table-bordered table-hover box-min-table">
											<thead class="bg-success">
											<tr>
												<th class="w150">英文名称</th>
												<th>中文标题</th>
												<th class="w150">数据来源配置/顺序</th>
												<th class="w200">其他配置</th>
												<th class="w150">操作</th>
											</tr>
											</thead>
											<tbody id="dataList2-body">
											</tbody>
										</table>
									</div>
							</div>
						</div>

					</div>
				</div>
			</div>
		</section>

		<div win-title="高级配置" class="modal fade" id="my_modal_other_set" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog" style="width:80%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">其他配置</font> 
						</h4>
					</div>

					<div class="modal-body">

						<div class="panel">

							<!-- tab content start -->
							<div class="panel-body">

								<div>
									<form class="form-horizontal addFormBody" role="form" id="seltionForm1" action="javascript:void(0)">
										<input class="form-control clean" type="hidden" name="input-attr-type">
										<table class="table table-bordered bordercolor" id="div_event_target_modal_content">
											<tbody>
											<tr class="tr_attrType_2">
												<td  class="w120" align="right"><label class="form-control-static">选择数据字典：</label>
												</td>
												<td colspan="2">
													<div class="form-group">
														<select data-live-search="true" id="seltionForm1_select_dictEname" name="select_dictEname"
																class="form-control selectpicker clean"
																data-obj-name="dictDataCate" data-dict-code="dymicSql" data-type-tag="select"
																data-colmun="{value:'cateEname',text:'cateEname,cateCname',other:''}"
																data-page-name="dict-list" data-form-name="searchForm"
																data-condition="" data-def="" data-dict-cate=""
																placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" >
															<option value="">-请选择--</option>
														</select>
													</div>
												</td>
											</tr>
											<tr class="tr_attrType_3">
												<td class="w120" rowspan="4" style="vertical-align: middle;"><label class="form-control-static">选择动态接口</label>
												</td>
												<td class="w200" align="right"><label class="form-control-static">pageName：</label>
												</td>
												<td>
													<div class="form-group">
														<div class="input-group">
															<input class="form-control clean" readonly="readonly" name="input-pageName" maxlength="50">
															<div class="input-group-addon red">
																<button type="button" class="btn btn-primary btn-xs" onclick="toOpenIus('div_event_target_modal_content')"> <i class="fa fa-cog"></i> 选择设置</button>
															</div>
														</div>
													</div>
												</td>
											</tr>
											<tr class="tr_attrType_3">
												<td  align="right"><label class="form-control-static">formName：</label>
												</td>
												<td>
													<div class="form-group">
														<input class="form-control clean" readonly="readonly" name="input-formName" maxlength="50">
													</div>
												</td>
											</tr>
<#--											<tr class="tr_attrType_3">-->
<#--												<td align="right"><label class="form-control-static">objName：</label>-->
<#--												</td>-->
<#--												<td>-->
<#--													<div class="form-group">-->
<#--														<input class="form-control clean" readonly="readonly" name="input-objName" maxlength="50">-->
<#--													</div>-->
<#--												</td>-->
<#--											</tr>-->
											<tr class="tr_attrType_3">
												<td align="right"><label class="form-control-static">选择匹配值的字段(value)：</label>
												</td>
												<td>
													<div class="form-group">
														<select data-live-search="true" id="seltionForm1_select_value" name="select_value"
																class="form-control selectpicker clean" >
															<option value="">-请选择--</option>
														</select>
													</div>
												</td>
											</tr>
											<tr class="tr_attrType_3">
												<td align="right"><label class="form-control-static">选择需导出的字段(text)：</label>
												</td>
												<td>
													<div class="form-group">
														<select data-live-search="true" id="seltionForm1_select_text" name="select_text"
																class="form-control selectpicker clean" >
															<option value="">-请选择--</option>
														</select>
													</div>
												</td>
											</tr>
											</tbody>
										</table>
									</form>
									<div class="pull-right"><button type="button" onclick="addChioseCofs('#seltionForm1')" class="btn btn-danger"> 确认选择 </button></div>
								</div>
							</div>
							<!-- tab content end -->
						</div>

					</div>
				</div>
				<!-- /.modal-content -->
			</div>
		</div>
		<!-- Main end -->
		<script type="text/template" id="dataList-template">
			<? for ( var i = 0; i < rows.length; i++) {?>
			<?var trIndex=i+'-'+new Date().getTime();?>
			<tr id="tr_config_<?=trIndex?>" data-exp-conf-id="">
				<td class="hidden">
					<input name="sysExportConf.pId" readonly="readonly" value="<?=pId?>" size="6"/>
					<input name="sysExportConf.attrName" readonly="readonly" value="<?=rows[i].metadata.dataAttr?>" size="6"/>
					<input name="sysExportConf.tableName" readonly="readonly" value="<?=rows[i].sortInfo.infoTableName?>" size="6"/>
					<input name="sysExportConf.attrField" readonly="readonly" value="<?=rows[i].metadata.dataShortName?>" size="6"/>
				</td>
				<td style="vertical-align: middle;">
					<?=(i+1)?>.<?=rows[i].metadata.dataShortName?>/<?=rows[i].metadata.dataAttr?><br/>
					<span style="font-size:9px;"><?=rows[i].metadata.dataFullName?>(<?=rows[i].sortInfo.sortName?>/<?=rows[i].sortInfo.objName?>)</span>
				</td>
				<td class=" text-center">
					<input onclick="checkedExpByObj(this)" value="1" type="checkbox" id="check_exp_<?=trIndex?>" name="checkbox_<?=rows[i].metadata.dataAttr?>"/>
				</td>
				<td>
					<div class="conf-box hidden">
						<input type="text" id="attrTitle_<?=trIndex?>" name="sysExportConf.attrTitle" class="form-control" maxlength="20"
						   value="<?=strUtil.doNull(rows[i].metadata.dataFullName,'')?>" placeholder="请输入导出名称" data-name="sysExportConf.attrTitle"/>
					</div>
				</td>
				<td>
					<div class="conf-box hidden">
						<select id="attrType_<?=trIndex?>" onchange="changeClick(this)" name="sysExportConf.attrType"
								data-name="sysExportConf.attrType" style="width:102px;">
							<option value="1">表内的原始值</option>
							<option value="2">匹配数据字典</option>
							<option value="3">匹配其他的表</option>
						</select>
						<input type="text" id="orderNo_<?=trIndex?>" name="sysExportConf.orderNo" value="<?=(i+1)?>" size="6" maxlength="3" data-name="sysExportConf.orderNo" style="width:26px;"/>
					</div>
				</td>
				<td>
					<div class="conf-box-dictCof hidden">
						<input type="text" id="dictCof_<?=trIndex?>" name="sysExportConf.dictCof" class="form-control" data-name="sysExportConf.dictCof"
						   value="" readonly="readonly" onclick="clickSelectionConf(this)" placeholder="点此选择配置"/>
					</div>
				</td>
				<td>
					<button  type="button" class="btn btn-primary btn-xs <?=rows[i].sortInfo.objName?>-stop" onclick="saveExportConf('tr_config_<?=trIndex?>')"> 保存配置</button>
				</td>
			</tr>
			<?}?>
		</script>

		<script type="text/template" id="dataList2-template">
			<? for ( var i = 0; i < rows.length; i++) {?>
			<?var trIndex=i+'-'+new Date().getTime();?>
			<tr id="tr_config_<?=trIndex?>" data-exp-conf-id="<?=rows[i].sysExportConf.infoId?>">
				<td class="hidden">
					<input name="sysExportConf.w_infoId" readonly="readonly" value="<?=rows[i].sysExportConf.infoId?>" size="6"/>
					<input name="sysExportConf.pId" readonly="readonly" value="<?=pId?>" size="6"/>
				</td>
				<td>
					<input type="text" id="attrField_<?=trIndex?>" name="sysExportConf.attrField" class="form-control" maxlength="20"
						   value="<?=strUtil.doNull(rows[i].sysExportConf.attrField,'')?>" placeholder="请输入英文名称" data-name="sysExportConf.attrField"/>
				</td>
				<td>
					<div class="conf-box">
						<input type="text" id="attrTitle_<?=trIndex?>" name="sysExportConf.attrTitle" class="form-control" maxlength="20"
							   value="<?=strUtil.doNull(rows[i].sysExportConf.attrTitle,'')?>" placeholder="请输入导出名称" data-name="sysExportConf.attrTitle"/>
					</div>
				</td>
				<td>
					<div class="conf-box">
						<select id="attrType_<?=trIndex?>" onchange="changeClick(this)" name="sysExportConf.attrType"
								data-name="sysExportConf.attrType" style="width:102px;">
							<option value="1" <?if('1'==rows[i].sysExportConf.attrType){?>selected="selected"<?}?>>返回的原始值</option>
							<option value="2" <?if('2'==rows[i].sysExportConf.attrType){?>selected="selected"<?}?>>匹配数据字典</option>
							<option value="3" <?if('3'==rows[i].sysExportConf.attrType){?>selected="selected"<?}?>>匹配其他的表</option>
						</select>
						<input type="text" id="orderNo_<?=trIndex?>" name="sysExportConf.orderNo" value="<?=(i+1)?>" size="6" maxlength="3" data-name="sysExportConf.orderNo" style="width:26px;"/>
					</div>
				</td>
				<td>
					<div class="conf-box-dictCof <?if('1'==rows[i].sysExportConf.attrType){?> hidden<?}?>">
						<input type="text" id="dictCof_<?=trIndex?>" name="sysExportConf.dictCof" class="form-control" data-name="sysExportConf.dictCof"
							   value="<?=strUtil.doNull(rows[i].sysExportConf.dictCof,'')?>" readonly="readonly" onclick="clickSelectionConf(this)" placeholder="点此选择配置"/>
					</div>
				</td>
				<td>
					<button  type="button" class="btn btn-primary btn-xs" onclick="saveExportConf('tr_config_<?=trIndex?>')"> 保存配置</button>
					<button  type="button" class="btn btn-default btn-xs" onclick="delExportConf('tr_config_<?=trIndex?>','<?=rows[i].sysExportConf.infoId?>')"> <i class="fa fa-trash-o"></i> 删除</button>
				</td>
			</tr>
			<?}?>
		</script>

		<script>
            var clickMenu = "sysParamManager-list";
            var  myPage, dataListId, searchFormId;
            myPage = 10;
            dataListId = "dataList";
            searchFormId = "searchForm";
			var titleName = "${title}",pageName="${pageName}",formName="${formName}",modelTypes="${modelTypes}",curSysName='${sysParamSysName}',selected_counts=0;
			var curPid = formName+"_"+pageName,custom_table_name=curPid;
			var select_all_expTitleType_Obj = $("#select_all_expTitleType"),select_all_ifTitleCap_Obj = $("#select_all_ifTitleCap");
			var objNameArray = [];
			if(!strUtil.isNull(modelTypes)){
				var modelTypesArry = modelTypes.split(",");
				modelTypesArry.forEach(function (item,i) {
					objNameArray.push(item.split("s_")[1]);
				});
			}
			console.log('init.param',modelTypes,objNameArray,curSysName);
			$('.selectpicker').selectpicker('refresh');

			/**
             * 初始化数据字典，id传入#id 返回值Map用法：dictListMap["userType"][rows[i].userType]
             */
            var dictListMap = DictUtil.initDictAndDymic();
            $(function () {

				checkSysExportConf();

				getTableData();

				getSysExportConfDataList('2');
				//2、控制是否启用token
                //setToken();
            });
			function toBack(){
				var url = page_admin+'/project/sysParamManager-list';
				mytools.pjax(url);
			}
			function testExportData() {
				if(selected_counts==0){
					layer.msg("未选择导出字段，全部导出所有！");
				}
				FormUtil.exportDataByIusParam({'pageName':pageName,'formName':formName});
			}
            //加载字段列表数据
            function getTableData() {
				var paramMap = {};
				paramMap['pageName']='objName-table-pop';
				paramMap['formName']='searchForm';
				paramMap['sortInfo.sortId']='[metadata.sortId]';
				paramMap['sortInfo.wi_objName']=objNameArray.join(',');
				// paramMap['sortInfo.w_sysName']=curSysName;
				paramMap['orderBy']='sortInfo.sort_id,metadata.reserved1+0,metadata.data_attr';
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: 'get',
					url: common_list_url,
					data: paramMap,
					dataType: 'json',
					async: false,
					success: function (myData) {
						layer.close(index_load);
						console.log("metadata.res",myData);
						myData.pId=curPid;
						var data = baidu.template(dataListId + "-template", eval(myData));
						$("#" + dataListId + "-body").html(data);
						getSysExportConfDataList('1');
					}
				});
			}
			//加载已历史配置的数据，反显
			function getSysExportConfDataList(cofType){
				var index_load = layer.load(1, {shade: false});
				var paramData = {"pageName":"sys-export-conf","formName":"searchForm","sysExportConf.w_pId":curPid};
				switch (cofType) {
					case '1':
						paramData['sysExportConf.wn_tableName']=custom_table_name;
					break;
					case '2':
						paramData['sysExportConf.w_tableName']=custom_table_name;
						break;
				}
				$.ajax({
					type: 'get',
					url:common_list_url,
					data:paramData,
					dataType: 'json',
					success: function (myData) {
						layer.close(index_load);
						console.log(cofType+'-initSysExportConf.res',myData);
						switch (cofType) {
							case '1':
								$("#span_expCheckedTotal").text(myData.total);
								if(myData.flag=='T'&&myData.total>0){
									var tbdoyObj = $("#" + dataListId + "-body");
									for(var i=0;i<myData.rows.length;i++){
										var cofObj = myData.rows[i]['sysExportConf'];
										if(i==0){
											//1、获取第一个数据	表头全部按、 表头是否大写 配置给全局反显示
											var first_ifTitleCap_val = myData.rows[0]['sysExportConf']['ifTitleCap'];
											var first_expTitleType_val = myData.rows[0]['sysExportConf']['expTitleType'];
											select_all_ifTitleCap_Obj.val(first_ifTitleCap_val);
											select_all_expTitleType_Obj.val(first_expTitleType_val);
										}
										var attrName= cofObj['attrName'],infoId = cofObj['infoId'],attrType=cofObj['attrType'];
										var curCheckedObj = tbdoyObj.find("input[type='checkbox'][name='checkbox_"+attrName+"']");
										var curTrObj = curCheckedObj.parents("tr[data-exp-conf-id]");
										curTrObj.attr("data-exp-conf-id",infoId);
										curCheckedObj.prop("checked", true);
										for(var aitem in cofObj){
											// console.log(aitem,cofObj[aitem]);
											curTrObj.find("[data-name='sysExportConf."+aitem+"']").val(cofObj[aitem]);//反显同行定义data-name的同属性值
										}
										curTrObj.find(".conf-box").removeClass("hidden");
										switch (attrType) {
											case '2':
											case '3':
												curTrObj.find(".conf-box-dictCof").removeClass("hidden");
												break;
										}
									}
								}
								break;
							case '2':
								myData.pId=curPid;
								var data2 = baidu.template(dataListId + "2-template", eval(myData));
								$("#" + dataListId + "2-body").html(data2);
								break;
						}
					}
				});
			}
			//点击某行，控制是否开启导出 功能
			function checkedExpByObj(ob) {
				var curTrObj = $(ob).parents("tr");
				var trId = curTrObj.attr("id");
				var isChecked = $(ob).is(":checked");
				var infoId = curTrObj.attr("data-exp-conf-id");
				console.log(trId,isChecked,infoId);
				if(isChecked){
					curTrObj.find(".conf-box").removeClass("hidden");
					//保存
					saveExportConf(trId)
				}else{
					curTrObj.find(".conf-box").addClass("hidden");
					curTrObj.find(".conf-box-dictCof").addClass("hidden");
					//删除
					if(!strUtil.isNull(infoId)){
						delExportConf(trId,infoId);
					}
				}
				count_expCheckedTot();
			}
			function count_expCheckedTot() {
				selected_counts=$("#" + dataListId + "-body").find("input[type='checkbox']:checked").length;
				$("#span_expCheckedTotal").text(selected_counts);
			}
			//切换数据来源下拉框，控制其他配置是否显示还是隐藏
			function changeClick(ob) {
				var curTrObj = $(ob).parents("tr");
				var curVal= $(ob).val();
				switch (curVal) {
					case '1':
						curTrObj.find(".conf-box-dictCof").addClass("hidden");
						curTrObj.find(".conf-box-dictCof").find("input").val('');
						break;
					case '2':
					case '3':
						curTrObj.find(".conf-box-dictCof").find("input").val('');
						curTrObj.find(".conf-box-dictCof").removeClass("hidden");
						break;
				}
			}
			var thisCurrDictCofObj = null;
			//选择其他配置（数据字典、动态表ius参数）
			function clickSelectionConf(ob) {
				// var index_load = layer.load(1, {shade: false});
				var obj = $(ob);
				thisCurrDictCofObj = obj;
				var curTrObj = obj.parents("tr");
				var curVal= obj.val();
				var attrType = curTrObj.find("select[name='sysExportConf.attrType']").val();
				console.log('clickSelectionConf',attrType,curVal);
				var formId = "#seltionForm1";
				mytools.cleanData(formId);
				$(formId).find("tr").addClass("hidden");
				$(formId).find("input[name='input-attr-type']").val(attrType);
				$(".tr_attrType_"+attrType).removeClass("hidden");
				$('.selectpicker').selectpicker('refresh');
				$('#my_modal_other_set').modal("show");
			}
			function addChioseCofs(formId) {
				var attrType = $(formId).find("input[name='input-attr-type']").val();
				var dictCofJson = {};
				switch (attrType) {
					case '2':
						dictCofJson.dict=$(formId).find("select[name='select_dictEname']").val();
						if(strUtil.isNull(dictCofJson.dict)){
							layer.msg("请选择数据字典");
							return;
						}
						break;
					case '3':
						dictCofJson.pageName=$(formId).find("input[name='input-pageName']").val();
						dictCofJson.formName=$(formId).find("input[name='input-formName']").val();
						dictCofJson.val=$(formId).find("select[name='select_value']").val();
						dictCofJson.text=$(formId).find("select[name='select_text']").val();
						if(strUtil.isNull(dictCofJson.val)||strUtil.isNull(dictCofJson.text)){
							layer.msg("请选择匹配的value,text");
							return;
						}
						break;
				}
				thisCurrDictCofObj.val(JSON.stringify(dictCofJson));
				console.log('addChioseCofs',attrType,dictCofJson);
				$('#my_modal_other_set').modal("hide");
			}
			//弹出选择ius参数框
			var loginWin = null;
			var pageNameTempObj,formNameTempObj,objNameTempObj;
			function toOpenIus(divId){
				var divObj = $("#"+divId);
				pageNameTempObj = divObj.find("input[name='input-pageName']");
				formNameTempObj = divObj.find("input[name='input-formName']");
				objNameTempObj = divObj.find("input[name='input-objName']");
				var pageName = pageNameTempObj.val();
				pageName=strUtil.doNull(pageName,'');
				var formName = formNameTempObj.val();
				loginWin = layer.open({
					type: 2,
					title:"IUS参数选择",
					shadeClose: false,
					shade: 0.6,
					area: ['1100px', '600px'],
					offset: '10px',
					content: page_admin+"/project/sysParamManager-list-sample?sysEname="+curSysName+"&pageName="+pageName+"&formName="+formName //iframe的url
				});
			}
			//选中IUS后回调方法
			function preIusCallBack(ob){
				layer.close(loginWin);
				var pageName = $(ob).attr("pagename");
				var formName = $(ob).attr("formname");
				var infoId = $(ob).attr("infoid");
				var modelTypes = $(ob).attr("modeltypes");
				pageNameTempObj.val(pageName);
				formNameTempObj.val(formName);
				var modelObjName=modelTypes,objName=modelTypes;
				if(modelTypes.indexOf(",")>-1){
					modelObjName = modelTypes.split(",")[0];
				}
				if(modelObjName.indexOf("_")>-1){
					objName = modelObjName.split("_")[1];
					objNameTempObj.val(objName);//objName
				}
				getTableMetadataAttr(objName);
				console.log('preIusCallBack',pageName,formName,objName);
			}
			//查询表字段
			function getTableMetadataAttr(objName) {
				var paramMap = {};
				paramMap['pageName']='objName-table-pop';
				paramMap['formName']='searchForm';
				paramMap['sortInfo.sortId']='[metadata.sortId]';
				paramMap['sortInfo.w_objName']=objName;
				paramMap['orderBy']='metadata.reserved1+0,metadata.data_attr';
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: 'get',
					url: common_list_url,
					data: paramMap,
					dataType: 'json',
					async: false,
					success: function (myData) {
						layer.close(index_load);
						console.log(objName+".metadata.res",myData);
						var optionHtml = "<option value=''>--请选择--</option>";
						if(myData.flag=='T'){
							for(var a=0;a<myData.rows.length;a++){
								var itemObj = myData.rows[a]["metadata"];
								var option_val = itemObj['dataAttr'];
								var option_text = itemObj['dataAttr']+"-"+itemObj['dataFullName'];
								optionHtml+="<option value='"+option_val+"'>"+option_text+"</option>";
							}
						}
						$("#seltionForm1_select_value").html(optionHtml);
						$("#seltionForm1_select_value").selectpicker('refresh');
						$("#seltionForm1_select_text").html(optionHtml);
						$("#seltionForm1_select_text").selectpicker('refresh');
					}
				});
			}
			//检查导出表是否配置，平台版本可能没有此表
			function checkSysExportConf() {
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: 'get',
					url:common_list_url,
					data:{"pageName":"sys-param-manager","formName":"searchForm","sysParamManager.w_pageName":'sys-export-conf'},
					dataType: 'json',
					success: function (myData) {
						layer.close(index_load);
						// console.log('checkSysExportConf.res',myData);
						if(myData.total==0){
							alert("该版本因缺失配置表，请联系平台管理员完善补充后再重新配置！");
							toBack();
						}
					}
				})
			}
			//增加自定义项
			function addExportCustItem() {
				var tableBody2 =  $("#dataList2-body").find("tr").length;
				var nextNo = tableBody2+1;
				var paramData={"pageName":"sys-export-conf","formName":"addForm","sysExportConf.pId":curPid,"sysExportConf.tableName":custom_table_name,"sysExportConf.attrType":'1'};
				paramData['sysExportConf.ifTitleCap']=select_all_ifTitleCap_Obj.val();
				paramData['sysExportConf.expTitleType']=select_all_expTitleType_Obj.val();
				paramData['sysExportConf.orderNo']=nextNo;
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: "post",
					url: common_submit_url,
					data: paramData,
					dataType: "json",
					success: function (myData) {
						layer.close(index_load);
						console.log('save.res',myData);
						if (myData.flag != "T") {
							layer.alert("保存失败！");
						}else{
							getSysExportConfDataList('2');
						}
					}
				});
			}

            //保存配置数据
            function saveExportConf(trId) {
				var trObj = $("#"+trId);
				var tableObj = trObj.parents("table").eq(0);
				var cofTypeVal  = tableObj.attr("data-coftype");
				var infoId = trObj.attr("data-exp-conf-id");
				var paramData={"pageName":"sys-export-conf","formName":"addForm"};
				if(!strUtil.isNull(infoId)){
					paramData['formName']='editForm';
					paramData['sysExportConf.w_infoId']=infoId;
				}
				var is_vald = true;
				trObj.find("[name]").each(function () {
					var c_name = $(this).attr("name");
					// console.log('save.item->',c_name,c_val);
					if('checkbox'==$(this).attr('type')) return;
					var c_val = $(this).val();
					if(c_name=='sysExportConf.dictCof' && strUtil.isNull(c_val)){
						var trobj_attrType_val = trObj.find("select[name='sysExportConf.attrType']").val();
						if('1'!=trobj_attrType_val){
							layer.tips('请完成其他配置！', '#'+$(this).attr("id"), {tips: 1});
							is_vald = false;
							return false;
						}
					}
					if(c_name=='sysExportConf.orderNo'){
						if(strUtil.isNull(c_val) || isNaN(c_val)){
							layer.tips('此项序号必须是数字！', '#'+$(this).attr("id"), {tips: 1});
							is_vald = false;
							return false;
						}
					}
					if(c_name=='sysExportConf.attrField' && '2'==cofTypeVal){//自定义配置情况下，属性名称=字段名称
						paramData['sysExportConf.attrName']=c_val;
					}
					paramData[c_name]=c_val;
				});
				paramData['sysExportConf.ifTitleCap']=select_all_ifTitleCap_Obj.val();
				paramData['sysExportConf.expTitleType']=select_all_expTitleType_Obj.val();
				console.log(cofTypeVal+'.save.req->',is_vald,paramData);
				if(!is_vald){return}
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: "post",
					url: common_submit_url,
					data: paramData,
					dataType: "json",
					success: function (myData) {
						layer.close(index_load);
						console.log('save.res',myData);
						if (myData.flag != "T") {
							layer.alert("保存失败！");
							refresh();
						}else{
							layer.msg("保存完成！");
							if(myData.result){
								trObj.attr("data-exp-conf-id",myData.result['sysExportConf_infoId']);
							}
						}
					}
				});
            }
			function changeExportConfAttr(attrName,attrVal) {
				var paramData={"pageName":"sys-export-conf","formName":"editForm"};
				paramData['sysExportConf.'+attrName]=attrVal;
				paramData['sysExportConf.w_pId']=curPid;
				console.log('changeExportConfAttr.req->',paramData);
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: "post",
					url: common_submit_url,
					data: paramData,
					dataType: "json",
					success: function (myData) {
						layer.close(index_load);
						console.log('changeExportConfAttr.res',myData);
						if (myData.flag != "T") {
							layer.msg("保存设置失败！");
						}else{
							layer.msg("保存设置完成！");
						}
						refresh();
					}
				});
			}
			function delExportConf(trId,infoId) {
				var trObj = $("#"+trId);
				var tableObj = trObj.parents("table").eq(0);
				var cofTypeVal  = tableObj.attr("data-coftype");
				var paramData={"pageName":"sys-export-conf","formName":"delForm",'sysExportConf.w_infoId':infoId};
				var index_load = layer.load(1, {shade: false});
				$.ajax({
					type: "post",
					url: common_submit_url,
					data: paramData,
					dataType: "json",
					success: function (myData) {
						layer.close(index_load);
						console.log('del.res',myData);
						if (myData.flag != "T") {
							layer.alert("删除失败！");
						}
						switch (cofTypeVal) {
							case '1':
								getTableData();
								break;
							case '2':
								getSysExportConfDataList(cofTypeVal);
								break;
						}
					}
				});
			}
            function refresh() {
                getTableData();
                getSysExportConfDataList('2');
            }
            function setToken() {
                $.ajax({
                    type: 'get',
                    url: '${ctx}/sendPage/token?token=true',
                    dataType: 'text',
                    success: function (myData) {
                        console.log(myData);
                        $('#formToken').val(myData);
                    }
                });
            }
            //自定义方法
            //1.定义校验规则-定义
            function setValidate(id) {
                $(id).bootstrapValidator({
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    }, /** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
                    fields: {
                        "tablePrefix": {
                            validators: {
                                notEmpty: {
                                    message: '自定义属性不能为空！'
                                },
                                regexp: {
                                    regexp: /^[a-z]+$/,
                                    message: '只能是小写英文字母！'
                                }
                            }
                        },
                        "sortCode": {
                            validators: {
                                notEmpty: {
                                    message: '自定义属性不能为空！'
                                },
                                regexp: {
                                    regexp: /^[a-z_ ]+$/,
                                    message: '只能是小写英文字母，多个单词使用下划线间隔！'
                                }
                            }
                        },
                        "sortName": {
                            validators: {
                                notEmpty: {
                                    message: '自定义属性不能为空！'
                                },
                                /* regexp: {
                                     regexp:/^[\u4e00-\u9fa5]*$/,
                                     message: '请输入数据表的中文名！'
                                 }*/
                            }
                        },
                        "objName": {
                            validators: {
                                notEmpty: {
                                    message: '自定义属性不能为空！'
                                },
                                regexp: {
                                    regexp: /^[a-zA-Z]+$/,
                                    message: '请填写英文数据表名-驼峰式！'
                                }
                            }
                        },
                    }
                });
            }

		</script>

	</div>
	<!-- /.content-wrapper -->
	<!-- foot start -->
	<#include "/common/plateform/foot.ftl">
	<!-- foot start -->
</div>


</body>


</html>

